﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<mesoBoard.Common.IPluginDetails>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

    <fieldset>
        <legend><%= Html.ThemeImage("cog.png") %> Install Plugin</legend>

        <% var results = ViewData["InstallResults"] as mesoBoard.Web.Models.PluginInstall;
            if(results != null) { %>
            <p>
                <ul>
                    <li>SQL query error: <%= results.SQL %></li>
                    <li>Plugin configurations error: <%= results.Configs %></li>
                </ul>
            </p>
            <% } %>


        <h2>
            Name: <%= Model.Name %>
        </h2>

        <h3>
            Description:
        </h3>

        <p>
            <%= Model.Description  %>
        </p>

        <p>
            Are you sure you want to install this plugin?
        </p>

        <p>
            <% using(Html.BeginForm("InstallPlugin", "Plugins")){ %>
                <input type="hidden" value="<%= ViewData["AssemblyName"] %>" name="AssemblyName" />
                <input type="submit" value="Yes, install this plugin" />
                <%= Html.ActionLink("No, don't install this plugin", "Index", "Plugins") %>
            <%} %>
        </p>

        <p>
            Below are the changes that will occur when this plugin is installed:
        </p>

        <h4>
            The following plugin configurations will be added
        </h4>
        
        <table class="form_table">
            <tr>
                <th>Name</th>
                <th>Value</th>
                <th>Note</th>
            </tr>
            <%  if (Model.InstallDetails.GetConfigs() != null)
                {
                    foreach (var item in Model.InstallDetails.GetConfigs())
                    { %>
                <tr>
                    <td>
                        <%= item.Name%>
                    </td>
                    <td>
                        <%= item.Value%>
                    </td>
                    <td>
                        <%= item.Note%>
                    </td>
                </tr>
                <% }
                }
                else { %>
                <tr>
                    <td colspan="3">
                        No Configurations
                    </td>
                </tr>
                <% }  %>

        </table>

        <h4>
            The following SQL commands will be run
        </h4>

        <pre style="overflow: scroll; width:1000px; height: 300px; border: solid 1px #ccc">
            <%= Model.InstallDetails.GetSQL() %>
        </pre>

    </fieldset>

</asp:Content>
